from tkinter import *
from tkinter import messagebox
import random

def pick_student():
    start = int(start_entry.get())
    end = int(end_entry.get())
    students = list(range(start, end+1))
    random.shuffle(students)
    result_label.config(text="抽到的学号是：" + str(students[0]))
    students = students[1:] # 确认每一个学号可以在一轮抽号中只出现一次

root = Tk()
root.title("学号抽取器")
root.eval('tk::PlaceWindow %s center' % root.winfo_toplevel())
root.geometry("250x200")

start_label = Label(root, text="起始学号：")
start_label.pack()

start_entry = Entry(root)
start_entry.insert(0, "1")
start_entry.pack()

end_label = Label(root, text="结束学号：")
end_label.pack()

end_entry = Entry(root)
end_entry.insert(0, "42")
end_entry.pack()

pick_button = Button(root, text="抽取学号", command=pick_student)
pick_button.pack()

about_button = Button(root, text="关于作者", command=lambda: messagebox.showinfo(title="提示", message="作者gitee主页:\nhttps://gitee.com/huhuvmb88\n去给个star吧!"))
about_button.pack()

result_label = Label(root, text="")
result_label.config(font=("Arial", 20))
result_label.pack()

root.mainloop()